package com.sna.snaapplication.service.UserSys;

import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.sna.snaapplication.entity.usercore.UserRole;
import com.sna.snaapplication.mapper.UserRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserRoleService {

    @Autowired
    UserRoleMapper userRoleMapper;


    //保存用户ID和角色ID


    public Integer saveUserRole(UserRole userRole){
        return userRoleMapper.insert(userRole);
    }


    public boolean checkRole(Integer id) {
        MPJLambdaWrapper<UserRole> wrapper=new MPJLambdaWrapper<>();
        wrapper.eq(UserRole::getUserId,id)
                .eq(UserRole::getRoleId,1);
        UserRole userRole=userRoleMapper.selectOne(wrapper);
        return userRole!=null;
    }
}